<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">

    {{fullname}} - {{fullname}}

    <hr>
    {{getfullname()}} - {{getfullname()}}

  </div>

  <script>

    var vm = new Vue({
      el: "#app",
      computed: {
        fullname: {
          get() {
            console.log('computed')
            return this.firstname + this.lastname;
          },
          set(val) {
            this.firstname = val;
          }
        }
      },
      data: {
        firstname: 'liu',
        lastname: 'huihui'
      },
      methods: {
        getfullname() {
          console.log('methods')
          return this.firstname + this.lastname;
        }
      },
      watch: {
        firstname(newval, oldval) {
          console.log(newval, oldval)
        },
        lastname(newval, oldval) {
          console.log(newval, oldval)
        }

      }

    })
  </script>
</body>

</html>